package com.yztc.ui.classify;

import com.yztc.bean.classify.ClassifyBean;
import com.yztc.http.RetrofitService;
import com.yztc.utils.HttpHelper;

import rx.Observable;
import rx.Observer;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;


/**
 * Created by MengLingzhang on 2016/10/6.
 */
public class ClassifyModle implements ClassifyContract.Modle{

    @Override
    public void getVerticalClassifyBean(String baseUrl, final ClassifyContract.OnLoadListener loadListener) {
        Observable observable= (Observable) HttpHelper
                .getInstance()
                .getRetrofit(baseUrl)
                .create(RetrofitService.class)
                .getClassifyBean();
        observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<ClassifyBean>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        loadListener.onFailure(e);
                    }

                    @Override
                    public void onNext(ClassifyBean classifyBean) {
                        loadListener.onSuccess(classifyBean);
                    }

                });
    }

}
